from django.contrib.admin import ModelAdmin, register
from .models import Notices, About



@register(About)
class AboutAdmin(ModelAdmin):
    ordering = ('id',)
    fieldsets = (
        ("类型", {'fields': ['type']}),
        ("内容", {'fields': ['title', 'content', 'url', 'dates']}),
    )
    list_display = ('id', 'type', 'title', 'dates')

    # type = models.IntegerField(verbose_name="类型", choices=((1, "Q&A"), (2, "声明说明"), (3, "捐赠"), (4, "关于")),
    #                            default=1)
    # title = models.CharField(verbose_name="标题", max_length=64)
    # content = models.TextField(verbose_name="内容", max_length=512)
    # dates = models.DateTimeField(verbose_name="时间", default=timezone.now)
    # url = models.TextField(verbose_name="链接", max_length=512, null=True, blank=True, default="")

@register(Notices)
class NoticeAdmin(ModelAdmin):
    ordering = ('-id',)
    fieldsets = (
        ("基本信息", {'fields': ['title', 'is_show', 'is_important', 'date']}),
        ("内容",
         {'fields': ['content', 'inner_web_url', 'addition_action_title', 'addition_action_url',
                     'background_color_1', 'background_color_2', 'background_color_3']}),
    )
    list_display = ('id', 'title', 'content', 'is_show', 'is_important', 'date')
    search_fields = ('title', 'is_show', 'is_important', 'date')
    list_per_page = 20